<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span>
</span><span id="line-2"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.CmmToAsm.Instr</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-3"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#RegUsage"><span class="hs-identifier">RegUsage</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-4"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#noUsage"><span class="hs-identifier">noUsage</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-5"></span><span>        </span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier">GenBasicBlock</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.html#blockId"><span class="hs-identifier">blockId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-6"></span><span>        </span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier">ListGraph</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-7"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatCmm"><span class="hs-identifier">NatCmm</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-8"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatCmmDecl"><span class="hs-identifier">NatCmmDecl</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-9"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatBasicBlock"><span class="hs-identifier">NatBasicBlock</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-10"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#topInfoTable"><span class="hs-identifier">topInfoTable</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#entryBlocks"><span class="hs-identifier">entryBlocks</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier">Instruction</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-13"></span><span class="hs-special">)</span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span class="hs-keyword">where</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html"><span class="hs-identifier">GHC.Platform.Reg</span></a></span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Collections.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Collections</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Label</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#topInfoTable"><span class="hs-identifier">topInfoTable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Config.html"><span class="hs-identifier">GHC.CmmToAsm.Config</span></a></span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-comment">-- | Holds a list of source and destination registers used by a</span><span>
</span><span id="line-30"></span><span class="hs-comment">--      particular instruction.</span><span>
</span><span id="line-31"></span><span class="hs-comment">--</span><span>
</span><span id="line-32"></span><span class="hs-comment">--   Machine registers that are pre-allocated to stgRegs are filtered</span><span>
</span><span id="line-33"></span><span class="hs-comment">--      out, because they are uninteresting from a register allocation</span><span>
</span><span id="line-34"></span><span class="hs-comment">--      standpoint.  (We wouldn't want them to end up on the free list!)</span><span>
</span><span id="line-35"></span><span class="hs-comment">--</span><span>
</span><span id="line-36"></span><span class="hs-comment">--   As far as we are concerned, the fixed registers simply don't exist</span><span>
</span><span id="line-37"></span><span class="hs-comment">--      (for allocation purposes, anyway).</span><span>
</span><span id="line-38"></span><span class="hs-comment">--</span><span>
</span><span id="line-39"></span><span class="hs-keyword">data</span><span> </span><span id="RegUsage"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#RegUsage"><span class="hs-identifier hs-var">RegUsage</span></a></span></span><span>
</span><span id="line-40"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span id="RU"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#RU"><span class="hs-identifier hs-var">RU</span></a></span></span><span>    </span><span class="hs-special">{</span><span>
</span><span id="line-41"></span><span>                </span><span id="reads"><span class="annot"><span class="annottext">RegUsage -&gt; [Reg]
</span><a href="GHC.CmmToAsm.Instr.html#reads"><span class="hs-identifier hs-var hs-var">reads</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>                </span><span id="writes"><span class="annot"><span class="annottext">RegUsage -&gt; [Reg]
</span><a href="GHC.CmmToAsm.Instr.html#writes"><span class="hs-identifier hs-var hs-var">writes</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-43"></span><span>                </span><span class="hs-special">}</span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="hs-comment">-- | No regs read or written to.</span><span>
</span><span id="line-46"></span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#noUsage"><span class="hs-identifier hs-type">noUsage</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#RegUsage"><span class="hs-identifier hs-type">RegUsage</span></a></span><span>
</span><span id="line-47"></span><span id="noUsage"><span class="annot"><span class="annottext">noUsage :: RegUsage
</span><a href="GHC.CmmToAsm.Instr.html#noUsage"><span class="hs-identifier hs-var hs-var">noUsage</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Reg] -&gt; [Reg] -&gt; RegUsage
</span><a href="GHC.CmmToAsm.Instr.html#RU"><span class="hs-identifier hs-var">RU</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-comment">-- Our flavours of the Cmm types</span><span>
</span><span id="line-50"></span><span class="hs-comment">-- Type synonyms for Cmm populated with native code</span><span>
</span><span id="line-51"></span><span class="hs-keyword">type</span><span> </span><span id="NatCmm"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatCmm"><span class="hs-identifier hs-var">NatCmm</span></a></span></span><span> </span><span id="local-6989586621681007659"><span class="annot"><a href="#local-6989586621681007659"><span class="hs-identifier hs-type">instr</span></a></span></span><span>
</span><span id="line-52"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.html#GenCmmGroup"><span class="hs-identifier hs-type">GenCmmGroup</span></a></span><span>
</span><span id="line-53"></span><span>                </span><span class="annot"><a href="GHC.Cmm.html#RawCmmStatics"><span class="hs-identifier hs-type">RawCmmStatics</span></a></span><span>
</span><span id="line-54"></span><span>                </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.html#RawCmmStatics"><span class="hs-identifier hs-type">RawCmmStatics</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span>                </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-type">ListGraph</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007659"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-keyword">type</span><span> </span><span id="NatCmmDecl"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatCmmDecl"><span class="hs-identifier hs-var">NatCmmDecl</span></a></span></span><span> </span><span id="local-6989586621681007656"><span class="annot"><a href="#local-6989586621681007656"><span class="hs-identifier hs-type">statics</span></a></span></span><span> </span><span id="local-6989586621681007655"><span class="annot"><a href="#local-6989586621681007655"><span class="hs-identifier hs-type">instr</span></a></span></span><span>
</span><span id="line-58"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.html#GenCmmDecl"><span class="hs-identifier hs-type">GenCmmDecl</span></a></span><span>
</span><span id="line-59"></span><span>                </span><span class="annot"><a href="#local-6989586621681007656"><span class="hs-identifier hs-type">statics</span></a></span><span>
</span><span id="line-60"></span><span>                </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.html#RawCmmStatics"><span class="hs-identifier hs-type">RawCmmStatics</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span>                </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-type">ListGraph</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007655"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-keyword">type</span><span> </span><span id="NatBasicBlock"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#NatBasicBlock"><span class="hs-identifier hs-var">NatBasicBlock</span></a></span></span><span> </span><span id="local-6989586621681007654"><span class="annot"><a href="#local-6989586621681007654"><span class="hs-identifier hs-type">instr</span></a></span></span><span>
</span><span id="line-65"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Cmm.html#GenBasicBlock"><span class="hs-identifier hs-type">GenBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007654"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-comment">-- | Returns the info table associated with the CmmDecl's entry point,</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- if any.</span><span>
</span><span id="line-70"></span><span id="local-6989586621681007695"><span id="local-6989586621681007697"><span id="local-6989586621681007698"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#topInfoTable"><span class="hs-identifier hs-type">topInfoTable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.html#GenCmmDecl"><span class="hs-identifier hs-type">GenCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007698"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007697"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-type">ListGraph</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007695"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007697"><span class="hs-identifier hs-type">i</span></a></span></span></span></span><span>
</span><span id="line-71"></span><span id="topInfoTable"><span class="annot"><span class="annottext">topInfoTable :: forall a i b. GenCmmDecl a (LabelMap i) (ListGraph b) -&gt; Maybe i
</span><a href="GHC.CmmToAsm.Instr.html#topInfoTable"><span class="hs-identifier hs-var hs-var">topInfoTable</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681007650"><span class="annot"><span class="annottext">LabelMap i
</span><a href="#local-6989586621681007650"><span class="hs-identifier hs-var">infos</span></a></span></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-type">ListGraph</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681007648"><span class="annot"><span class="annottext">GenBasicBlock b
</span><a href="#local-6989586621681007648"><span class="hs-identifier hs-var">b</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[GenBasicBlock b]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-72"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap i -&gt; Maybe i
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenBasicBlock b -&gt; BlockId
forall i. GenBasicBlock i -&gt; BlockId
</span><a href="GHC.Cmm.html#blockId"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">GenBasicBlock b
</span><a href="#local-6989586621681007648"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LabelMap i
</span><a href="#local-6989586621681007650"><span class="hs-identifier hs-var">infos</span></a></span><span>
</span><span id="line-73"></span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#topInfoTable"><span class="hs-identifier hs-var">topInfoTable</span></a></span><span> </span><span class="annot"><span class="annottext">GenCmmDecl a (LabelMap i) (ListGraph b)
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-74"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe i
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-comment">-- | Return the list of BlockIds in a CmmDecl that are entry points</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- for this proc (i.e. they may be jumped to from outside this proc).</span><span>
</span><span id="line-78"></span><span id="local-6989586621681007678"><span id="local-6989586621681007679"><span id="local-6989586621681007680"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#entryBlocks"><span class="hs-identifier hs-type">entryBlocks</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.html#GenCmmDecl"><span class="hs-identifier hs-type">GenCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007680"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007679"><span class="hs-identifier hs-type">i</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-type">ListGraph</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681007678"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span></span></span></span><span>
</span><span id="line-79"></span><span id="entryBlocks"><span class="annot"><span class="annottext">entryBlocks :: forall a i b. GenCmmDecl a (LabelMap i) (ListGraph b) -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.Instr.html#entryBlocks"><span class="hs-identifier hs-var hs-var">entryBlocks</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681007646"><span class="annot"><span class="annottext">LabelMap i
</span><a href="#local-6989586621681007646"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#ListGraph"><span class="hs-identifier hs-type">ListGraph</span></a></span><span> </span><span id="local-6989586621681007645"><span class="annot"><span class="annottext">[GenBasicBlock b]
</span><a href="#local-6989586621681007645"><span class="hs-identifier hs-var">code</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681007644"><span class="hs-identifier hs-var">entries</span></a></span><span>
</span><span id="line-80"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-81"></span><span>        </span><span id="local-6989586621681007642"><span class="annot"><span class="annottext">infos :: [KeyOf LabelMap]
</span><a href="#local-6989586621681007642"><span class="hs-identifier hs-var hs-var">infos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LabelMap i -&gt; [KeyOf LabelMap]
forall (map :: * -&gt; *) a. IsMap map =&gt; map a -&gt; [KeyOf map]
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapKeys"><span class="hs-identifier hs-var">mapKeys</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap i
</span><a href="#local-6989586621681007646"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-82"></span><span>        </span><span id="local-6989586621681007644"><span class="annot"><span class="annottext">entries :: [BlockId]
</span><a href="#local-6989586621681007644"><span class="hs-identifier hs-var hs-var">entries</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock b]
</span><a href="#local-6989586621681007645"><span class="hs-identifier hs-var">code</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-83"></span><span>                    </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681007642"><span class="hs-identifier hs-var">infos</span></a></span><span>
</span><span id="line-84"></span><span>                    </span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681007635"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681007635"><span class="hs-identifier hs-var">entry</span></a></span></span><span> </span><span class="annot"><span class="annottext">[b]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">[GenBasicBlock b]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-comment">-- first block is the entry point</span><span>
</span><span id="line-85"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681007635"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [BlockId] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681007642"><span class="hs-identifier hs-var">infos</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681007642"><span class="hs-identifier hs-var">infos</span></a></span><span>
</span><span id="line-86"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681007635"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [BlockId] -&gt; [BlockId]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681007642"><span class="hs-identifier hs-var">infos</span></a></span><span>
</span><span id="line-87"></span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#entryBlocks"><span class="hs-identifier hs-var">entryBlocks</span></a></span><span> </span><span class="annot"><span class="annottext">GenCmmDecl a (LabelMap i) (ListGraph b)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-88"></span><span>
</span><span id="line-89"></span><span class="hs-comment">-- | Common things that we can do with instructions, on all architectures.</span><span>
</span><span id="line-90"></span><span class="hs-comment">--      These are used by the shared parts of the native code generator,</span><span>
</span><span id="line-91"></span><span class="hs-comment">--      specifically the register allocators.</span><span>
</span><span id="line-92"></span><span class="hs-comment">--</span><span>
</span><span id="line-93"></span><span class="hs-keyword">class</span><span>   </span><span id="Instruction"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-var">Instruction</span></a></span></span><span> </span><span id="local-6989586621681007633"><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span>        </span><span class="hs-comment">-- | Get the registers that are being used by this instruction.</span><span>
</span><span id="line-96"></span><span>        </span><span class="hs-comment">--      regUsage doesn't need to do any trickery for jumps and such.</span><span>
</span><span id="line-97"></span><span>        </span><span class="hs-comment">--      Just state precisely the regs read and written by that insn.</span><span>
</span><span id="line-98"></span><span>        </span><span class="hs-comment">--      The consequences of control flow transfers, as far as register</span><span>
</span><span id="line-99"></span><span>        </span><span class="hs-comment">--      allocation goes, are taken care of by the register allocator.</span><span>
</span><span id="line-100"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-101"></span><span>        </span><span id="regUsageOfInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#regUsageOfInstr"><span class="hs-identifier hs-type">regUsageOfInstr</span></a></span></span><span>
</span><span id="line-102"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-103"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-104"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#RegUsage"><span class="hs-identifier hs-type">RegUsage</span></a></span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span>        </span><span class="hs-comment">-- | Apply a given mapping to all the register references in this</span><span>
</span><span id="line-108"></span><span>        </span><span class="hs-comment">--      instruction.</span><span>
</span><span id="line-109"></span><span>        </span><span id="patchRegsOfInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#patchRegsOfInstr"><span class="hs-identifier hs-type">patchRegsOfInstr</span></a></span></span><span>
</span><span id="line-110"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-111"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-113"></span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span>        </span><span class="hs-comment">-- | Checks whether this instruction is a jump/branch instruction.</span><span>
</span><span id="line-116"></span><span>        </span><span class="hs-comment">--      One that can change the flow of control in a way that the</span><span>
</span><span id="line-117"></span><span>        </span><span class="hs-comment">--      register allocator needs to worry about.</span><span>
</span><span id="line-118"></span><span>        </span><span id="isJumpishInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#isJumpishInstr"><span class="hs-identifier hs-type">isJumpishInstr</span></a></span></span><span>
</span><span id="line-119"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span>        </span><span class="hs-comment">-- | Give the possible destinations of this jump instruction.</span><span>
</span><span id="line-123"></span><span>        </span><span class="hs-comment">--      Must be defined for all jumpish instructions.</span><span>
</span><span id="line-124"></span><span>        </span><span id="jumpDestsOfInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#jumpDestsOfInstr"><span class="hs-identifier hs-type">jumpDestsOfInstr</span></a></span></span><span>
</span><span id="line-125"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-126"></span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span>        </span><span class="hs-comment">-- | Change the destination of this jump instruction.</span><span>
</span><span id="line-129"></span><span>        </span><span class="hs-comment">--      Used in the linear allocator when adding fixup blocks for join</span><span>
</span><span id="line-130"></span><span>        </span><span class="hs-comment">--      points.</span><span>
</span><span id="line-131"></span><span>        </span><span id="patchJumpInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#patchJumpInstr"><span class="hs-identifier hs-type">patchJumpInstr</span></a></span></span><span>
</span><span id="line-132"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-133"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-134"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span>        </span><span class="hs-comment">-- | An instruction to spill a register into a spill slot.</span><span>
</span><span id="line-138"></span><span>        </span><span id="mkSpillInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#mkSpillInstr"><span class="hs-identifier hs-type">mkSpillInstr</span></a></span></span><span>
</span><span id="line-139"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Config.html#NCGConfig"><span class="hs-identifier hs-type">NCGConfig</span></a></span><span>
</span><span id="line-140"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span>          </span><span class="hs-comment">-- ^ the reg to spill</span><span>
</span><span id="line-141"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- ^ the current stack delta</span><span>
</span><span id="line-142"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- ^ spill slot to use</span><span>
</span><span id="line-143"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span>        </span><span class="hs-comment">-- | An instruction to reload a register from a spill slot.</span><span>
</span><span id="line-147"></span><span>        </span><span id="mkLoadInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#mkLoadInstr"><span class="hs-identifier hs-type">mkLoadInstr</span></a></span></span><span>
</span><span id="line-148"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Config.html#NCGConfig"><span class="hs-identifier hs-type">NCGConfig</span></a></span><span>
</span><span id="line-149"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span>          </span><span class="hs-comment">-- ^ the reg to reload.</span><span>
</span><span id="line-150"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- ^ the current stack delta</span><span>
</span><span id="line-151"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>          </span><span class="hs-comment">-- ^ the spill slot to use</span><span>
</span><span id="line-152"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span>        </span><span class="hs-comment">-- | See if this instruction is telling us the current C stack delta</span><span>
</span><span id="line-155"></span><span>        </span><span id="takeDeltaInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#takeDeltaInstr"><span class="hs-identifier hs-type">takeDeltaInstr</span></a></span></span><span>
</span><span id="line-156"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-157"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-158"></span><span>
</span><span id="line-159"></span><span>        </span><span class="hs-comment">-- | Check whether this instruction is some meta thing inserted into</span><span>
</span><span id="line-160"></span><span>        </span><span class="hs-comment">--      the instruction stream for other purposes.</span><span>
</span><span id="line-161"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-162"></span><span>        </span><span class="hs-comment">--      Not something that has to be treated as a real machine instruction</span><span>
</span><span id="line-163"></span><span>        </span><span class="hs-comment">--      and have its registers allocated.</span><span>
</span><span id="line-164"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-165"></span><span>        </span><span class="hs-comment">--      eg, comments, delta, ldata, etc.</span><span>
</span><span id="line-166"></span><span>        </span><span id="isMetaInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#isMetaInstr"><span class="hs-identifier hs-type">isMetaInstr</span></a></span></span><span>
</span><span id="line-167"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-168"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-169"></span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span>        </span><span class="hs-comment">-- | Copy the value in a register to another one.</span><span>
</span><span id="line-173"></span><span>        </span><span class="hs-comment">--      Must work for all register classes.</span><span>
</span><span id="line-174"></span><span>        </span><span id="mkRegRegMoveInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#mkRegRegMoveInstr"><span class="hs-identifier hs-type">mkRegRegMoveInstr</span></a></span></span><span>
</span><span id="line-175"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-176"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span>          </span><span class="hs-comment">-- ^ source register</span><span>
</span><span id="line-177"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span>          </span><span class="hs-comment">-- ^ destination register</span><span>
</span><span id="line-178"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span>        </span><span class="hs-comment">-- | Take the source and destination from this reg -&gt; reg move instruction</span><span>
</span><span id="line-181"></span><span>        </span><span class="hs-comment">--      or Nothing if it's not one</span><span>
</span><span id="line-182"></span><span>        </span><span id="takeRegRegMoveInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#takeRegRegMoveInstr"><span class="hs-identifier hs-type">takeRegRegMoveInstr</span></a></span></span><span>
</span><span id="line-183"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-184"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span>        </span><span class="hs-comment">-- | Make an unconditional jump instruction.</span><span>
</span><span id="line-187"></span><span>        </span><span class="hs-comment">--      For architectures with branch delay slots, its ok to put</span><span>
</span><span id="line-188"></span><span>        </span><span class="hs-comment">--      a NOP after the jump. Don't fill the delay slot with an</span><span>
</span><span id="line-189"></span><span>        </span><span class="hs-comment">--      instruction that references regs or you'll confuse the</span><span>
</span><span id="line-190"></span><span>        </span><span class="hs-comment">--      linear allocator.</span><span>
</span><span id="line-191"></span><span>        </span><span id="mkJumpInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#mkJumpInstr"><span class="hs-identifier hs-type">mkJumpInstr</span></a></span></span><span>
</span><span id="line-192"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-193"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span>        </span><span class="hs-comment">-- Subtract an amount from the C stack pointer</span><span>
</span><span id="line-197"></span><span>        </span><span id="mkStackAllocInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#mkStackAllocInstr"><span class="hs-identifier hs-type">mkStackAllocInstr</span></a></span></span><span>
</span><span id="line-198"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-199"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-200"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span>        </span><span class="hs-comment">-- Add an amount to the C stack pointer</span><span>
</span><span id="line-203"></span><span>        </span><span id="mkStackDeallocInstr"><span class="annot"><a href="GHC.CmmToAsm.Instr.html#mkStackDeallocInstr"><span class="hs-identifier hs-type">mkStackDeallocInstr</span></a></span></span><span>
</span><span id="line-204"></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-205"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-206"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621681007633"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-207"></span></pre></body></html>